<template>
  <div class="alphabet" v-if="cityInfo" ref="area_scroll">
    <div class="scroll_wrap">
      <!-- 热门城市 -->
      <div class="hot_wrap areaList">
        <div class="title">热门城市</div>
        <ul class="hot_city">
          <li @click="updateCity(item.name)" v-for="(item,index) in cityInfo.hotCities" :key="index">{{ item.name }}</li>
        </ul>
      </div>
      <!-- 所有城市 -->
      <div class="city_wrap">
        <!-- 所有字母 -->
        <div class="city_alphabet areaList" v-for="(item,index) in keys" :key="index">
          <div class="title">{{ item }}</div>
          <ul @click="updateCity(city.name)" v-for="(city,indey) in cityInfo[item]" :key="indey" class="city_alphabet">
            <li>{{ city.name }}</li>
          </ul>
        </div>
      </div>

    </div>
  </div>
</template>

<script>
export default {
  name: 'MyAlphabet',
  props: {
    cityInfo: Object,
    keys: Array
  },
  methods: {
    updateCity(city) {
      this.$emit('updateCity', city)
    }
  }
}
</script>

<style lang="less" scoped>
.alphabet {
  .scroll_wrap {
    padding: 0 10px;
    .hot_wrap {
      padding-bottom: 45px;
      border-bottom: 1px solid #ccc;
      .title {
        font-size: 18px;
        padding: 5px 10px;
        color: #888;
      }
      .hot_city {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        padding: 0 10px;
        li {
          width: 30%;
          border: 1px solid #ccc;
          padding: 5px 16px;
          box-sizing: border-box;
          margin: 8px 10px;
          text-align: center;
          font-size: 16px;
          background-color: #eee;
        }
      }
    }
    .city_wrap {
      margin-top: 50px;
      .city_alphabet {
        padding: 0 8px;
        box-sizing: border-box;
        .title {
          margin: 20px 0;
          font-size: 18px;
        }
        .city_alphabet {
          padding: 14px 5px;
          border-bottom: 1px solid #ccc;
          li {
            font-size: 18px;
            font-weight: 500;
          }
        }
      }
    }
  }
}
</style>
